import { SaveGroupLocally } from '@/app/groups/[groupId]/save-recent-group'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card'
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/table'
import { getGroup, getGroupExpenses } from '@/lib/api'
import { ChevronRight, Plus } from 'lucide-react'
import Link from 'next/link'
import { notFound } from 'next/navigation'
export default async function GroupPage({
params: { groupId },
}: {
params: { groupId: string }
}) {
const group = await getGroup(groupId)
if (!group) notFound()
const expenses = await getGroupExpenses(groupId)
return (
<>
Expenses
Here are the expenses that you created for your group.
Title
Paid by
Paid for
Amount
{expenses.map((expense) => (
{expense.title}
{
group.participants.find(
(p) => p.id === expense.paidById,
)?.name
}
{expense.paidFor.map((paidFor, index) => (
{
group.participants.find(
(p) => p.id === paidFor.participantId,
)?.name
}
))}
$ {expense.amount.toFixed(2)}
))}
Participants
{group.participants.map((participant) => (
- {participant.name}
))}
>
)
}